package com.gxy.learn.design.model.create.factory.simple_factory;

/**
 * @description: 简单咖啡工厂
 * @author: gaoxueyong
 * @Date: 2022/11/6 22:05
 */
public class SimpleCoffeeFactory {
    public static Coffee create(String type) {
        Coffee coffee = null;
        if ("america".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException(String.format("暂无[%s]咖啡", type));
        }
        return coffee;
    }
}
